package com.javabasic.algorithm.leetcode;

public class RunningSumOf1dArray {

    /**
     * 前缀和
     * @param nums
     * @return
     */
    public int[] runningSum(int[] nums) {
        int len = nums.length;
        if (len < 2) return nums;
        int prefixSum = nums[0];
        for (int i = 1; i < len; i++) {
            prefixSum += nums[i];
            nums[i] = prefixSum;
        }
        return nums;
    }
}
